import java.util.Random;
public class MainOfException {
    public static void result(int x,int y) throws Exception {
        int A = 4*x - 4;
        int B = 2*x*x-4*x*y + y*y;
        if(A == 0 || B == 0)
            throw new ArithmeticException("A or B == 0");
        else {
            System.out.println("A = " + A);
            System.out.println("B = " + B);
            System.out.println("C = " + (double)A / (double)B );
            throw new Exception("program if ok!");
        }
    }


    public static void main(String[] args) {
        Random a = new Random();
        int x = a.nextInt(20);
        int y = a.nextInt(20);
        System.out.println("x = "+x);
        System.out.println("y = "+y);
        try {
            result(x, y);
        }
        catch (ArithmeticException e){
            System.out.println(e.getMessage());
        }
        catch (Exception e){
            System.out.println(e.getMessage());
        }
        finally {
            System.out.println("program is end");
        }
    }
}
